]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
systemActions: Add a screenshot UI action
authorIvan Molodetskikh <yalterz@gmail.com>
Fri, 17 Dec 2021 08:40:43 +0000 (11:40 +0300)
committerMarge Bot <marge-bot@gnome.org>
Fri, 4 Feb 2022 13:03:09 +0000 (13:03 +0000)
It waits for the overview to close because otherwise the screenshot UI
would capture the overview.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2106>

js/misc/systemActions.js

index 10cab9a9e2ec94a5fc6e06822b68994d74b6c02e..a45a21c165277c5357dc3337211c3a8ce1245f03 100644 (file)
@@ -4,6 +4,7 @@ const { AccountsService, Clutter, Gdm, Gio, GLib, GObject, Meta } = imports.gi;
 const GnomeSession = imports.misc.gnomeSession;
 const LoginManager = imports.misc.loginManager;
 const Main = imports.ui.main;
+const Screenshot = imports.ui.screenshot;
 
 const LOCKDOWN_SCHEMA = 'org.gnome.desktop.lockdown';
 const LOGIN_SCREEN_SCHEMA = 'org.gnome.login-screen';
@@ -20,6 +21,7 @@ const LOGOUT_ACTION_ID           = 'logout';
 const SUSPEND_ACTION_ID          = 'suspend';
 const SWITCH_USER_ACTION_ID      = 'switch-user';
 const LOCK_ORIENTATION_ACTION_ID = 'lock-orientation';
+const SCREENSHOT_UI_ACTION_ID    = 'open-screenshot-ui';
 
 let _singleton = null;
 
@@ -132,6 +134,14 @@ const SystemActions = GObject.registerClass({
             keywords: tokenizeKeywords(_('lock orientation;unlock orientation;screen;rotation')),
             available: false,
         });
+        this._actions.set(SCREENSHOT_UI_ACTION_ID, {
+            // Translators: The name of the screenshot UI action in search
+            name: C_('search-result', 'Take a Screenshot'),
+            iconName: 'applets-screenshooter-symbolic',
+            // Translators: A list of keywords that match the screenshot UI action, separated by semicolons
+            keywords: tokenizeKeywords(_('screenshot;screencast;snip;capture;record')),
+            available: true,
+        });
 
         this._loginScreenSettings = new Gio.Settings({ schema_id: LOGIN_SCREEN_SCHEMA });
         this._lockdownSettings = new Gio.Settings({ schema_id: LOCKDOWN_SCHEMA });
@@ -306,6 +316,9 @@ const SystemActions = GObject.registerClass({
         case LOCK_ORIENTATION_ACTION_ID:
             this.activateLockOrientation();
             break;
+        case SCREENSHOT_UI_ACTION_ID:
+            this.activateScreenshotUI();
+            break;
         }
     }
 
@@ -446,4 +459,18 @@ const SystemActions = GObject.registerClass({
 
         this._loginManager.suspend();
     }
+
+    activateScreenshotUI() {
+        if (!this._actions.get(SCREENSHOT_UI_ACTION_ID).available)
+            throw new Error('The screenshot UI action is not available!');
+
+        if (this._overviewHiddenId)
+            return;
+
+        this._overviewHiddenId = Main.overview.connect('hidden', () => {
+            Main.overview.disconnect(this._overviewHiddenId);
+            delete this._overviewHiddenId;
+            Screenshot.showScreenshotUI();
+        });
+    }
 });